3. Prove that the code terminates.